#ifndef USB_H
#define USB_H

#include <stdint.h>

/* ---------- EHCI 寄存器 ---------- */
typedef volatile struct {
    uint32_t usbcmd;
    uint32_t usbsts;
    uint32_t usbintr;
    uint32_t frindex;
    uint32_t ctrldssegment;
    uint32_t periodiclistbase;
    uint32_t asynclistaddr;
    uint32_t _pad[9];
    uint32_t configflag;
    uint32_t portsc[15];
} ehci_regs_t;

/* ---------- 数据结构 ---------- */
typedef struct {
    uint32_t next;
    uint32_t alt;
    uint32_t token;
    uint32_t buf[5];
} qtd_t;

typedef struct {
    uint32_t horizontal;
    uint32_t static_ep;
    uint32_t overlay[5];
} qh_t;

int usb_init();
void usb_read(int sector, uint8_t *addr);

#endif
